package com.yd.app.mapper;

import com.yd.app.mapper.provider.LoggerProvider;
import com.yd.domain.sys.Logger;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zy
 * @create 2018-03-12 14:14
 * @desc 日志mapper
 **/
@Repository
public interface LoggerMapper {
    /**
     * @Author: zy
     * @Desc: 添加日志
     * @Date:  2018/3/12
     * @Param
     */
    @Insert("insert into sys_logger(id,title,operUser,operTime,log_type,des,status,ipAddress,modelType,pref,suff)" +
            "values(#{log.id},#{log.title},#{log.operUser},#{log.operTime},#{log.log_type},#{log.des},#{log.status},#{log.ipAddress},#{log.modelType},#{log.pref},#{log.suff})")
    void addLogger(@Param("log") Logger logger);

    /**
     * @Author: zy
     * @Desc: 分页查询日志
     * @Date:  2018/3/12
     * @Param
     */
    @SelectProvider(method = "searchLoggerList",type= LoggerProvider.class)
    List<Logger> getLoggerList(@Param("searchParam") Logger searchParam, @Param("startRow") int startRow, @Param("pageSize") int pageSize);
   /**
    * @Author: zy
    * @Desc: 查询日志数量
    * @Date:  2018/3/12
    * @Param
    */
    @SelectProvider(method = "searchLoggerCount",type= LoggerProvider.class)
    int getLoggerListCount(@Param("searchParam") Logger searchParam);
    /**
     * 根据id获取日志信息
     * @param id
     * @return
     */
    @Select("select log.*,user.realName as operUserName  from sys_logger log left join view_user user on log.operUser=user.id where log.id=#{id} ")
    Logger getLogById(@Param("id") String id);
}
